var lineOption = function(data,head){
/*	
	var name = data.name;
	var aggType = data.aggType;
	var dimensionData = data.data;
	var xValue=[];
	var yValue=[];
//	console.log(JSON.stringify(dimensionData))
	if (dimensionData) {
		dimensionData.sort(compare("Name"));
		for(var i=0;i<dimensionData.length;i++){
			xValue.push(dimensionData[i].Name);
			yValue.push(dimensionData[i][aggType]);
		}
	}else{
		xValue.push(name);
		yValue.push(data[aggType]);
		if(!data[aggType]){
			yValue = [];
		}
	}
	*/
	var nameData = [];
	var xValue = [];
	var seriesData = [];
	var min = null;
	var max = null;
	for ( var i = 0; i < data.length; i++) {
		nameData.push(data[i].name);
		var aggType = data[i].aggType;
		var dimensionData = data[i].data;
		var cdId = data[i].cdId;
		
		if (dimensionData) {
//			dimensionData.sort(compare("Name"));
			var yValue = [];
			for ( var j = 0; j < dimensionData.length; j++) {
				var temp = dimensionData[j];
				if (i==0) {
					xValue.push(temp.Name);
				}
				yValue.push(temp[cdId]);
				//取y轴最大值与最小值
				if (i==0 && j==0) {
					min = temp[cdId];
					max = temp[cdId];
				}else{
					if (min > temp[cdId]) {
						min = temp[cdId];
					}
					if (max < temp[cdId]) {
						max = temp[cdId];
					}
				}
				
			}
			var s = {
					name:data[i].name,
					type:'line',
					data:yValue
			};
			seriesData.push(s);
		}
	}

	return {
				 title : {
				        text: head,				//主标题
//				        subtext: subhead		//副标题
				        x:'center'
				    },
			    tooltip : {
			    	show:false,
			        trigger: 'axis'
			    },
			    legend: {
			    	show:true,
			    	x:'left',
			    	y:'bottom',
			        data:nameData
			    },
			    toolbox: {
			        show : false,
			        feature : {
			            mark : {show: false},
			            dataView : {show: false, readOnly: false},
			            magicType : {show: false, type: ['line', 'bar', 'stack', 'tiled']},
			            restore : {show: false},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            type : 'category',
			            boundaryGap : false,
			            axisLabel: {
			            	show: true,
			            	rotate: -45
			            	},
			            data : xValue
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value',
			            min : 'dataMin',
			            max : 'dataMax'
			        }
			    ],
			    series : seriesData,
			          noDataLoadingOption:{
			            	text :"暂无数据",
			            	    effect : 'bubble',
			            	    effectOption:{
			            	    	backgroundColor:"#fff",
			            	    	effect:{
			            	    		n:0
			            	    	}
			            	    },
			            	    textStyle : {
			            	        fontSize : 20
			            	    }
			            }   
			};
}